package com.java.test5;

import java.util.Scanner;

/**
 * @author shkstart
 * @create 2021-01-14 15:28
 */
public class Test5 extends Exception {
    public static void main(String[] args) {
        try {
            GenderException();
        } catch (Test5 test5) {
            test5.printStackTrace();
        }

    }

    public static void GenderException() throws Test5 {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入你的性别");
        String gender = sc.next();
        if (gender.equals('男') || gender.equals('女')) {
            System.out.println("你的性别为:" + gender);
        } else {
            throw new Test5();
        }
    }
}
